package com.winner.strategy_pattern.phoneplan;

import org.springframework.stereotype.Service;

@Service
public class TencentKingCardServiceImpl implements PhonePlanStrategy {
    @Override
    public double doOperation(int talkTime, int flow) {
        int exceedFlow = flow <= 40 * 1024 ? 0 : (flow - 40 * 1024);
        double result = 20 + 0.2 * talkTime + 0.1 * exceedFlow;
        System.out.println("使用腾讯大王卡套餐资费为：" + result +"元");
        return result;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        PhonePlanFactory.register("TENCENT_KING_CARD", this);
    }
}
